<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>拉萨市财政局投资评审管理系统  </title>
    <link rel="stylesheet" href="css/style.css">
    <script src="js/jquery-1.10.2.min.js"></script>
    <style>
        .scan-tab-bor .cancel-null{
            right:77px;
        }
    </style>
</head>
<body>
<!--main-header start-->
<div class="main-header">
    <div class="w-1200 clearfix">
        <div class="header-logo fl"><a href=""><img src="images/logo.png"></a> </div>
        <!--header-person start-->
         
        <div id="head_login"></div>
    <script type="text/javascript">
      
      $("#head_login").load("login_common.html");
    </script>

        <!--header-person end-->
        <!--header-nav start-->
        <div class="header-nav fr">
            <ul class="nav">
                <li class="on"><a href="/leaaderindex.html">待分配项目</a> </li>
                <li><a href="/leaaderindex2.html">已分配项目</a> </li>
                <span id="art"></span>
                <script>$("#art").load("artcommon.html")</script>
            </ul>
        </div>
        <!--header-nav end-->
    </div>
</div>
<!--main-header end-->
<!--scan-container start-->
<div class="scan-container w-1200" id="mainbox">
    <!--scan-step start-->
    <div class="scan-step clearfix">
        <div class="scan-step-hd fl">项目进度</div>
        <div class="scan-step-bd">
            <div class="step-num">
                <span class="circle">1</span>
                <p>资料准备</p>
            </div>
            <div class="step-num">
                <span class="circle">2</span>
                <p>预审中</p>
            </div>
            <div class="step-num">
                <span class="circle">3</span>
                <p>评审中</p>
            </div>
            <div class="step-num">
                <span class="circle">4</span>
                <p>复核中</p>
            </div>
            <div class="step-num">
                <span class="circle">5</span>
                <p>定审中</p>
            </div>
            <div class="step-num">
                <span class="circle">6</span>
                <p>完结</p>
            </div>
        </div>
    </div>
    <!--scan-step end-->
    <!--scan-main start-->
        <!--scan-main start-->
    <div class="scan-main">
        <!--scan-box start-->
        <div id="sm"></div>
        <script>$("#sm").load("common-iteminfo.html")</script>
        <!--scan-box end-->
        <!--scan-box start-->
        <div class="scan-box" id="filebox">
            <script>
                $("#filebox").load("filedetail.html");
            </script>
        </div>
        <!--scan-box end-->
    </div>
    <!--scan-main end-->
    <!--scan-tab start-->
    <div class="scan-tab" id="expbox">
        <!--scan-tab-nav start-->
        <div class="scan-tab-nav clearfix">
            <div class="li iszj">专家分配</div>
            <div class="li isjg">机构分配</div>
        </div>
        <!--scan-tab-nav end-->
        <!--scan-tab-content start-->
        <div class="scan-tab-content" id="zjbox">
            <!---------------------------------------------------------------11-29start------------------->
            <!--scan-tab-box start-->
            <div class="scan-tab-box">
                <div class="scan-tab-tit">自动分配专家</div>
                <div class="scan-tab-con clearfix boxsystem">
                    <!--scan-tab-li start-->
                   
                  
                    <!--scan-tab-li end-->
                    <!--scan-tab-li start-->
                    
                    <!--scan-tab-li end-->
                </div>
            </div>
            <!--scan-tab-box end-->
            <!--scan-tab-box start-->
            <div class="scan-tab-box">
                <div class="scan-tab-tit">推荐专家</div>
                <div class="scan-tab-con clearfix boxsystemall">
                    <!--scan-tab-li start-->
               
             
                    
                   
        
                    <!--scan-tab-li end-->
                </div>
            </div>
            <div class="add-bottom boxbtn">
               
           
            </div>
            <!--add-bottom end-->
            <!--驳回申请弹窗 start-->
            <div class="sy-alert scan-alert animated" sy-enter="zoomIn" sy-leave="zoomOut" sy-type="confirm" sy-mask="true" id="alert1">
                <div class="sy-title">
                    请填写项目申请驳回理由
                    <div class="scan-alert-close" onClick="syalert.syhide('alert1')"></div>
                </div>
                <div class="scan-alert-content">
                    <textarea rows="6" class="txt"></textarea>
                </div>
                <div class="scan-alert-bot">
                    <button class="login-btn" onClick="ok('alert1')">立即驳回</button>
                </div>
            </div>
            <!--驳回申请弹窗 end-->
        </div>
        <!--scan-tab-content end-->
        <!--scan-tab-content start-->
        <div class="scan-tab-content" id="jgbox">
            <!---------------------------------------------------------------11-29start------------------->
            <!--scan-tab-box start-->
            <div class="scan-tab-box">
                <div class="scan-tab-tit">自动分配机构</div>
                <div class="scan-tab-con clearfix" id="fpzj">
                    <!--scan-tab-li start-->
                  
                    <!--scan-tab-li end-->
                </div>
            </div>
            <!--scan-tab-box end-->
            <!--scan-tab-box start-->
            <div class="scan-tab-box">
                <div class="scan-tab-tit">推荐机构</div>
                <div class="scan-tab-con clearfix" id="suggestjg">
                </div>
            </div>
            <div class="add-bottom boxbtn" id="actfp"> 
            </div>
            <div class="sy-alert scan-alert animated" sy-enter="zoomIn" sy-leave="zoomOut" sy-type="confirm" sy-mask="true" id="alert2">
                <div class="sy-title">
                    请填写项目申请驳回理由
                    <div class="scan-alert-close" onClick="syalert.syhide('alert2')"></div>
                </div>
                <div class="scan-alert-content">
                    <textarea rows="6" id="reason"  class="txt"></textarea>
                </div>
                <div class="scan-alert-bot">
                    <button class="login-btn" onClick="passitem(0)">立即驳回</button>
                </div>
            </div>
            <script>
                function ok(id){
                    syalert.syhide(id);
                }
            </script>
            <!--驳回申请弹窗 end-->
        </div>
        <!--scan-tab-content end-->
    </div>
    <!--scan-tab end-->

    <!------------------------------------------------11-29新加js start----------------------------------------------->
    <script type="text/javascript" src="js/auth.js"></script>
   
    <script type="text/javascript">
           
var id=getQueryString("id");
console.log(id);
$.get(HTTP_HOST+"api/Leader/detail?id="+id,function(res){

        if (res.code == 200) {
            item = res.result;
                $("#xmbd").html(item.xmbd);
                $("#xmlxr").html(item.contactor);
                $("#address").html(item.address);
                $("#name").html(item.name);
                $("#type").html(item.type);
                $("#owner").html(item.owner);
                $("#industry").html(item.industry);
                $("#lxwh").html(item.lxnumber);
                $("#yjbh").html(item.yjbh);
                $("#wtdw").html(item.wtdw);
                $("#wtdwlxr").html(item.wtdwcontactor);
                $("#wtdwlxrdh").html(item.wtdwcontactorphone);
                $("#cash").html(item.cash);
            var index = getstat(item.status);
            $(".step-num").each(function(k,obj){
                if(k<=index){
                    $(obj).addClass("on");
                }  
            });
            if(item.status == 1){
                $(".boxbtn").html(`<button class="login-btn" onclick="confirmExpt(`+item.isjg+`)">立即分配</button>
              `);
            }else{

                $("#expbox").hide();

            }
        if (item.isjg == true) {
            $(".iszj").hide();
            $(".isjg").addClass("on");
            $("#jgbox").addClass("active");
if(Object.keys(item.assign.system).length>0){
             var jg_info = item.assign.system[0];
        var fpzj = `<div class="scan-tab-li hover">
                        <div class="scan-tab-bor">
                            <div class="t scan-tab-t">`+jg_info.assgin_displayname+`<img src="images/v.png"><i>1</i></div>
                            <div class="pro">
                                项目类型：
                                <span>类型1      </span>
                                <span>类型2 </span>
                                <span>类型3</span>
                            </div>
                            <button class="choice dis" onClick="selectExpt(`+jg_info.assign_eid+`,this)" data-assign-id=`+jg_info.assign_eid+`>选定</button>
                            <button class="cancel" onClick="cancelExpt(`+jg_info.assign_eid+`,this)" data-assign-id=`+jg_info.assign_eid+`>取消</button>
                        </div>
                    </div>`;
                    $("#fpzj").html(fpzj);

}
                    var aljgs = item.allexps.exjg;
                    var all_jglist = "";
                    $.each(aljgs,function(k,v){
                        var actbutton = null;
                        if(v.ischoosed==true){

                            actbutton =`
                            <button class="choice dis" onClick="selectExpt(`+v.id+`,this)" data-assign-id=`+v.id+`>选定</button>
                            <button class="cancel" onClick="cancelExpt(`+v.id+`,this)" data-assign-id=`+v.id+`>取消</button>`;
                        }else{
                            actbutton =`
                            <button class="choice" onClick="selectExpt(`+v.id+`,this)" data-assign-id=`+v.id+`>选定</button>
                            <button class="cancel dis" onClick="cancelExpt(`+v.id+`,this)" data-assign-id=`+v.id+`>取消</button>`;
                        }
                       all_jglist += ` <div class="scan-tab-li hover">
                        <div class="scan-tab-bor">
                            <div class="t scan-tab-t">`+v.displayname+`<img src="images/v.png"><i>1</i></div>
                            <div class="pro">
                                项目类型：
                                <span>类型1</span>
                                <span>类型2 </span>
                                <span>类型3</span>
                            </div>
                            `+actbutton+`
                        </div>
                    </div>`;
                    });

                    $("#suggestjg").html(all_jglist);

        }else{
            $(".iszj").addClass("on");
            $("#zjbox").addClass("active");
            $(".isjg").hide();
            var zjopt = "";
            if(Object.keys(item.assign.system).length>0){
                var systems = item.assign.system;
                $.each(systems,function(k,v){
                    var group ="";
                    var gbtn = "";
                    if(v.isgroupleader == 1){
                       group ="组长";
                       gbtn = `<button class="choice dis" onClick="selectp(`+v.assign_eid+`,this)">选定</button>
                            <button class="cancel" onClick="celp(`+v.assign_eid+`,this)">取消</button>
                            <button class="set dis" onClick="setgroup(`+v.assign_eid+`,this)">设为组长</button>
                            <button class="cancel-null" style="right:85px" onClick="celgroup(`+v.assign_eid+`,this)">取消组长</button>`
                    }else{

                        gbtn = `<button class="choice dis" onClick="selectp(`+v.assign_eid+`,this)">选定</button>
                            <button class="cancel" onClick="celp(`+v.assign_eid+`,this)">取消</button>
                            <button class="set" onClick="setgroup(`+v.assign_eid+`,this)">设为组长</button>
                            <button class="cancel-null dis" onClick="celgroup(`+v.assign_eid+`,this)">取消 组长</button>`
                    }


                    zjopt+=`<div class="scan-tab-li hover">
                        <div class="scan-tab-bor">
                            <div class="t scan-tab-t">`+v.assgin_displayname+`<span class="tip">`+group+`</span><img src="images/v.png"><i>1</i></div>
                            <div class="tel">联系方式：<span>15823569872</span></div>
                            <div class="shan">
                                擅长领域：
                               `+v.good+`
                            </div>
                           `+gbtn+`

                        </div>
                    </div>`;  
                });

                $(".boxsystem").html(zjopt);
            }

            if(Object.keys(item.allexps.exp).length>0){
                var systemsall = item.allexps.exp;
                var allbox="";
                $.each(systemsall,function(k,v){
                    var actb = null;

                    var isg="";

                     var go = "";

                     if(v.isgroup==true){
                        isg = "组长";
                        go  =`<button class="set dis" onClick="setgroup(`+v.id+`,this)">设为组长</button>
                            <button class="cancel-null" style="right:78px" onClick="celgroup(`+v.id+`,this)">取消组长</button>`;
                     }else{
                         go=`<button class="set" onClick="setgroup(`+v.id+`,this)">设为组长</button>
                            <button class="cancel-null dis" style="right:78px" onClick="celgroup(`+v.id+`,this)">取消组长</button>`;
                     }


                    if(v.ischoosed==true){

                actb =`<button class="choice dis" onClick="selectp(`+v.id+`,this)" data-assign-id=`+v.id+`>选定</button>
                                <button class="cancel" onClick="celp(`+v.id+`,this)" data-assign-id=`+v.id+`>取消</button>`+go;

                                }else{

                             actb =`<button class="choice" onClick="selectp(`+v.id+`,this)" data-assign-id=`+v.id+`>选定</button>
                                <button class="cancel dis" onClick="celp(`+v.id+`,this)" data-assign-id=`+v.id+`>取消</button>`+go;
                     }
                     
                    allbox+=`<div class="scan-tab-li hover">
                        <div class="scan-tab-bor">
                            <div class="t scan-tab-t">`+v.displayname+`<span class="tip">`+isg+`</span><img src="images/v.png"><i>1</i></div>
                            <div class="tel">联系方式：<span>`+v.phone+`</span></div>
                            <div class="shan">
                                擅长领域：
                                `+v.good+`
                            </div>
                           `+actb+`
                        </div>
                    </div>`;  
                });
                
                $(".boxsystemall").html(allbox);

            }

        }
        }

},'JSON');

function confirmExpt(isjg){
    if(isjg == 1){

        $.post("/api/Leader/confirm",{"itemid":id},function(res){

        if(res.result.code == 200){
            alert("分配完成");
            window.location.reload();
        }else{
            alert(res.result.msg);
        }


        },'json');

    }else{

        $.post("/api/Leader/confirmZJ",{"itemid":id},function(res){

if(res.result.code == 200){
    alert("分配完成");
    location.href="/leaaderindex2.html";
}else{
    alert(res.result.msg);
}


},'json');

    }

}


function checkstatus(itemid){
    var ret = false;
    $.ajax({
        url:"/api/leader/getassign?id="+itemid,
        type:'get',
        async:false,
        success:function(data){

            if(data.result.code==200){
                ret = true;
            }else{
                alert(data.result.msg);
                ret = false;
            }

        }


    });

    return ret;

}


function cancelExpt(uid,obj){

    $.post("/api/Leader/cancelExpt",{"userid":uid,"itemid":id},function(res){

if(res.result.code !=200){
    alert(res.result.msg);
}else{
    alert(res.result.msg);
    window.location.reload();
}



},'Json');

}


function confirmUser(){}
function selectExpt(uid,obj){

    var isexist = checkstatus(id);

    if(isexist){

        $.post("/api/Leader/selectExpt",{"userid":uid,"itemid":id},function(res){

            if(res.result.code !=200){
                alert(res.result.msg);
            }else{

                alert("选择成功");
            }
        },'Json');

       $(obj).addClass("dis")
       $(obj).siblings(".cancel").removeClass("dis");

    }
}

function cancelUser(uid,obj){
    $(obj).removeClass("dis")
    $(obj).siblings(".choice").addClass("dis");
}




function celp(aid,obj){

    $.post("/api/Leader/cancelZJ",{"id":aid,"itemid":id},function(res){

    if(res.result.code !=200){
        alert(res.result.msg);
    }else{
        
        $(obj).addClass("dis")
        $(obj).siblings(".choice").removeClass("dis");
        alert(res.result.msg);
}
},'Json');
}



function selectp(uid,obj){

    $.post("/api/Leader/selectZJ",{"userid":uid,"itemid":id},function(res){

    if(res.result.code !=200){
        alert(res.result.msg);
    }else{
        
        $(obj).addClass("dis")
        $(obj).siblings(".cancel").removeClass("dis");
        alert(res.result.msg);
    }
    },'Json');
    }


function celgroup(uid,obj){



    $.post("/api/Leader/celgroup",{"userid":uid,'itemid':id},function(res){


if(res.result.code !=200){
    alert(res.result.msg);
}else{

    $(obj).removeClass("dis")
          
            $(obj).siblings(".set").toggleClass("dis");

    alert("成功取消组长");
    window.location.reload();
}

},'Json');}


function setgroup(uid,obj){
    $.post("/api/Leader/setgroup",{"userid":uid,'itemid':id},function(res){


        if(res.result.code !=200){
            alert(res.result.msg);
        }else{

            $(obj).addClass("dis");
            $(obj).siblings(".cancel-null").toggleClass("dis");


            alert("成功设定为组长");
            window.location.reload();
        }

    },'Json');
}
</script>


<script>
    // $(function(){
    //     $(".cancel").click(function(){
    //         $(this).toggleClass("dis").siblings(".cancel").removeClass("dis")
    //         $(this).siblings(".choice").toggleClass("dis");
    //     })
    //     $(".cancel-null").click(function(){
    //         $(this).toggleClass("dis").siblings(".cancel-null").removeClass("dis")
    //         $(this).siblings(".scan-tab-li .t").addClass("dis");
    //         $(this).siblings(".scan-tab-li .set").removeClass("dis");
    //         $(this).siblings(".choice").toggleClass("dis");
    //     })
    //     $(".choice").click(function(){
    //         $(this).toggleClass("dis").siblings(".choice").removeClass("dis")
    //         $(this).siblings(".cancel").toggleClass("dis");
    //     })
    //     $(".scan-tab-li .set").click(function(){
    //         $(this).toggleClass("dis").siblings(".set").removeClass("dis")
    //         $(this).siblings(".scan-tab-li .t").toggleClass("dis");
    //         $(this).siblings(".choice").toggleClass("dis");
    //         $(this).siblings(".cancel-null").toggleClass("dis");
    //     })
    // })
</script>
<!------------------------------------------------------11-29新加js end---------------------------------------------------->
<script>
    $(function () {
        $(".scan-tab-nav .li").off("click").on("click", function () {
            var index = $(this).index();
            $(this).addClass("on").siblings().removeClass("on");
            $(".scan-tab-content").eq(index).addClass("active").siblings().removeClass("active");
        });
    });
</script>
<link rel="stylesheet" href="js/alert/syalert.min.css">
<script src="js/alert/syalert.min.js"></script>
<script>
    function ok(id){
        syalert.syhide(id);
    }

    function passitem(){
        var reason = $("#reason").val();
        $.post("api/Leader/reject",{"id":id,"reason":reason},function(res){

                if(res.result.code==200){
                    alert("已拒绝此项目");
                    window.location.reload();
                }else{
                    alert(res.result.msg);
                }
        },'JSON');
    }
</script>

</body>
</html>
